#include<iostream>
#include<cstring>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
const int N=1e4+10;
int f[N];
struct family{
	int id;
	int num;
	double cnt,res;
}fa[N],arr[N];
bool cmp(family a ,family b)
{
	if(a.res==b.res)
	return a.id<b.id;
	return a.res>b.res;
}
int find(int id)
{
	if(f[id]==id)
	return id;
	return f[id]=find(f[id]);
}
void join(int x,int y)
{
	int fx=find(x);
	int fy=find(y);
	int minn=min(fx,fy);
	int maxx=max(fx,fy);
	if(fx!=fy)
	{
		f[maxx]=minn;
		fa[minn].num+=fa[maxx].num;
		fa[minn].cnt+=fa[maxx].cnt;
		fa[minn].res+=fa[maxx].res;
	}
}
int n;
int main()
{
	cin>>n;
	for(int i=0;i<=9999;i++)
	f[i]=i,fa[i].num=1;
	set<int> st,se;
	for(int i=1;i<=n;i++)
	{
		int id;
		cin>>id;
		for(int j=0;j<2;j++)
		{
			int fa;
			cin>>fa;
			if(fa!=-1)
			join(fa,id);
		}
		int k;
		cin>>k;
		while(k--)
		{
			int fc;
			cin>>fc;
			join(fc,id);
		}
		int u;
		double v;
		cin>>u>>v;
		int fi=find(id);
		fa[fi].cnt+=u,fa[fi].res+=v;
		st.insert(fi);
	}
	for(auto a:st)
	se.insert(find(a));
	int i=0;
	for(auto a:se)
	{
		arr[i].id=a;
		arr[i].num=fa[a].num;
		arr[i].cnt=(double)fa[a].cnt/fa[a].num;
		arr[i++].res=(double)fa[a].res/fa[a].num;
	}
	sort(arr,arr+i,cmp);
    cout<<i<<endl;
	for(int j=0;j<i;j++)
	printf("%04d %d %.3f %.3f\n",arr[j].id,arr[j].num,arr[j].cnt,arr[j].res);
	return 0;
}
